<template>
  <div>
    <template v-for="(side, index) in sides">
      <news-type
        v-if="side.linkType === 'newsType'"
        :key="index"
        :type-id="side.link"
        :title="side.value"
      />
      <div v-else-if="side.linkType === 'basicConfig'" :key="index">
        <config-group-show :config-id="side.link" />
      </div>
    </template>
  </div>
</template>

<script>

import { getByCode, getEditData } from '@/api/basicConfig/index'

import newsType from '@/components/newsType'
import configGroupShow from '@/components/config-group-show'

export default {
  name: 'Sides',
  components: {
    newsType, configGroupShow
  },
  data() {
    return {
      sides: []
    }
  },
  created() {
    getByCode({
      classifyCode: 'sides'
    }).then(res => {
      this.sides = res.data.basicItems
      this.sides.forEach(side => {
        if (side.linkType === 'basicConfig') {
          getEditData(side.link).then(sr => {
            side.subSide = sr.data.basicItems
            console.log(side.subSide)
          })
        }
      })
    })
  }
}
</script>

<style scoped>
.side-block {
  margin: 5px;
}
</style>
